#include <iostream>
#include "Interpolation.h"
#include <fstream>

double f(double x)
{
    return 1.0 / (1.0 + x * x);
}


int main()
{
    Newton B;
    vector<double> x;
    vector<double> fi;
    double x_i;

    vector<double> *p;
    vector<string> polys;

    for (int n = 2; n <= 8; n += 2)
    {
        for (int i = 0; i <= n; i++)
        {
            x_i = -5.0 + 10.0 * i / (double)n;
            x.push_back(x_i);
            fi.push_back(f(x_i));
        }
        p = B.interpolation(x, fi);

        polys.push_back(generate_poly_rat(*p, x));
    }
    
    ofstream out;
    out.open("./date/B.polynomials", ios::out);
    for (auto i : polys)
    {
        out << i << endl;
    }
    out.close();
    return 0;
}
